SYSFS_PCI_DEV_SUBDEVICE_PATH = '/subsystem_device'
SYSFS_PCI_DEV_CLASS_PATH = '/class'
SYSFS_PCIBACK_PATH = '/bus/pci/drivers/pciback/'
+SYSFS_PCISTUB_PATH = '/bus/pci/drivers/pci-stub/'
LSPCI_CMD = 'lspci'
os.write(fd, dw)
os.close(fd)
-def find_all_devices_owned_by_pciback():
+def find_all_assignable_devices():
+ ''' devices owned by pcibak or pci-stub can be directly assigned to
+ guest with IOMMU (VT-d or AMD IOMMU), find all these devices.
+ '''
sysfs_mnt = find_sysfs_mnt()
pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH
pci_names = os.popen('ls ' + pciback_path).read()
for pci in pci_list:
dev = PciDevice(parse_pci_name(pci))
dev_list = dev_list + [dev]
+
+ pcistub_path = sysfs_mnt + SYSFS_PCISTUB_PATH
+ pci_names = os.popen('ls ' + pcistub_path).read()
+ pci_list = extract_the_exact_pci_names(pci_names)
+ for pci in pci_list:
+ dev = PciDevice(parse_pci_name(pci))
+ dev_list = dev_list + [dev]
+
return dev_list
def transform_list(target, src):
return
for pci_dev in devs:
dev = PciDevice(parse_pci_name(pci_dev))
- if dev.driver == 'pciback':
+ if dev.driver == 'pciback' or dev.driver == 'pci-stub':
continue
err_msg = 'pci: %s must be co-assigned to the same guest with %s' + \
- ', but it is not owned by pciback.'
+ ', but it is not owned by pciback or pci-stub.'
raise PciDeviceAssignmentError(err_msg % (pci_dev, self.name))
def do_FLR(self):
return sxpr
def CheckSiblingDevices(self, domid, dev):
- """ Check if all sibling devices of dev are owned by pciback
+ """ Check if all sibling devices of dev are owned by pciback or pci-stub
"""
if not self.vm.info.is_hvm():
return
#no dom0 drivers bound to sdev
continue
- if sdev.driver!='pciback':
- raise VmError(("pci: PCI Backend does not own\n "+ \
- "sibling device %s of device %s\n"+ \
- "See the pciback.hide kernel "+ \
- "command-line parameter or\n"+ \
- "bind your slot/device to the PCI backend using sysfs" \
+ if sdev.driver!='pciback' and sdev.driver!='pci-stub':
+ raise VmError(("pci: PCI Backend and pci-stub don't\n "+ \
+ "own sibling device %s of device %s\n"\
)%(sdev.name, dev.name))
return
raise VmError("pci: failed to locate device and "+
"parse it's resources - "+str(e))
- if dev.driver!='pciback':
- raise VmError(("pci: PCI Backend does not own device "+ \
- "%s\n"+ \
- "See the pciback.hide kernel "+ \
- "command-line parameter or\n"+ \
- "bind your slot/device to the PCI backend using sysfs" \
- )%(dev.name))
+ if dev.driver!='pciback' and dev.driver!='pci-stub':
+ raise VmError(("pci: PCI Backend and pci-stub don't own "+ \
+ "device %s\n") %(dev.name))
if dev.has_non_page_aligned_bar and arch.type != "ia64":
raise VmError("pci: %s: non-page-aligned MMIO BAR found." % dev.name)
# if arch.type != "ia64":
# dev.do_FLR()
- PCIQuirk(dev)
+ if dev.driver == 'pciback':
+ PCIQuirk(dev)
if not self.vm.info.is_hvm():
# Setup IOMMU device assignment
raise VmError("pci: failed to locate device and "+
"parse it's resources - "+str(e))
- if dev.driver!='pciback':
- raise VmError(("pci: PCI Backend does not own device "+ \
- "%s\n"+ \
- "See the pciback.hide kernel "+ \
- "command-line parameter or\n"+ \
- "bind your slot/device to the PCI backend using sysfs" \
- )%(dev.name))
+ if dev.driver!='pciback' and dev.driver!='pci-stub':
+ raise VmError(("pci: PCI Backend and pci-stub don't own device "+ \
+ "%s\n") %(dev.name))
# Need to do FLR here before deassign device in order to terminate
# DMA transaction, etc